package com.maxmlr.music.song.service.transfer;

import com.maxmlr.music.admin.entity.User;
import com.maxmlr.music.common.util.DateUtil;
import com.maxmlr.music.song.entity.Special;
import com.maxmlr.music.song.param.SpecialInfoParam;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @ClassName SingerTransfer
 * @Description TODO
 * @Author maxiao
 * @Date 2020/6/7 下午10:24
 * @Version V1.0
 */
@Component
public class SpecialTransfer {

    public SpecialInfoParam po2SpecialInfoParam(Special special) {
        SpecialInfoParam specialInfoParam = new SpecialInfoParam();
        specialInfoParam.setId(special.getId());
        specialInfoParam.setSingerId(special.getSingerId());
        //specialInfoParam.setSingerName();
        //specialInfoParam.setType();
        //specialInfoParam.setNation();
        specialInfoParam.setSpecialName(special.getSpecialName());
        specialInfoParam.setHeadImgId(special.getHeadImgId());
        //specialInfoParam.setHeadImg();
        specialInfoParam.setHeat(special.getHeat());
        specialInfoParam.setChoice(special.getChoice());
        specialInfoParam.setCreateTime(DateUtil.getDateTimeStr(special.getCreateTime()));
        specialInfoParam.setUpdateTime(DateUtil.getDateTimeStr(special.getUpdateTime()));
        return specialInfoParam;
    }

    public Special po2Special(SpecialInfoParam param, User adminUser) {
        Date date = DateUtil.getDate();
        Special special = new Special();
        special.setSingerId(param.getSingerId());
        special.setSpecialName(param.getSpecialName());
        special.setHeat(param.getHeat());
        special.setChoice(param.getChoice());
        special.setHeadImgId(param.getHeadImgId());
        special.setCreateUserId(adminUser.getId());
        special.setUpdateUserId(adminUser.getId());
        special.setCreateTime(date);
        special.setUpdateTime(date);
        return special;
    }

    public Special fullSpecial(Special special, SpecialInfoParam param, User adminUser) {
        Date date = DateUtil.getDate();
        special.setSingerId(param.getSingerId());
        special.setSpecialName(param.getSpecialName());
        special.setHeat(param.getHeat());
        special.setChoice(param.getChoice());
        special.setHeadImgId(param.getHeadImgId());
        special.setUpdateUserId(adminUser.getId());
        special.setUpdateTime(date);
        return special;
    }
}
